//
//  def_additive_expression.h
//  compilation
//
//  Created by Kevin Le perf on 17/01/12.
//  Copyright (c) 2012 e2co technologie. All rights reserved.
//

#ifndef compilation_def_additive_expression_h
#define compilation_def_additive_expression_h

/*
 additive_expression
 : multiplicative_expression {printf("additive_expression\n");}
 | additive_expression '+' multiplicative_expression {printf("additive_expression\n");}
 | additive_expression '-' multiplicative_expression {printf("additive_expression\n");}
 ; */

struct def_additive_expression{
	void * parent;
	int type;
	struct def_multiplicative_expression * multiplicative_expression;
	struct def_additive_expression * additive_expression;
};

struct def_additive_expression * additive_expression_create(void * parent){
	struct def_additive_expression * d = malloc(sizeof(*d));
	d->type = 0;
	d->parent = parent;
	return d;
}

void additive_expression_print(struct def_additive_expression * a){
	switch(a->type){
		case 1:
			multiplicative_expression_print(a->multiplicative_expression);
			break;
		case 2:
			additive_expression_print(a->additive_expression);
			printf("+");
			multiplicative_expression_print(a->multiplicative_expression);
			break;
		default:
		case 3:
			additive_expression_print(a->additive_expression);
			printf("-");
			multiplicative_expression_print(a->multiplicative_expression);
			break;
	}
}
#endif
